package com.example.consumer;

import lombok.extern.log4j.Log4j2;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageClientExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 消费者,只关注orderly-topic消息队列中，tag=order的消息
 */
@Log4j2
@Component
@RocketMQMessageListener(topic = "orderly-topic", consumerGroup = "orderly-consumer-group",selectorExpression = "order")
public class OrderlyOrderConsumer implements RocketMQListener<Message> {

    @Override
    public void onMessage(Message message) {
        String msg=new String(message.getBody());
        String messageId=((MessageClientExt)message).getMsgId();



        log.info("orderly-consumer-group收到消息：" + msg+","+messageId);
    }
}
